/*
 * @Description: 登录页面
 * @Author: iamsmiling
 * @Date: 2021-05-24 21:35:04
 * @LastEditTime: 2021-05-31 18:13:59
 */
import 'package:credit_business_circle/R/R.dart';
import 'package:credit_business_circle/pages/login/login_controller.dart';
import 'package:credit_business_circle/routes/app_routes.dart';
import 'package:flutter/material.dart';
import 'package:get/get.dart';

class LoginPage extends GetView<LoginController> {
  const LoginPage({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return Theme(
      data: Get.theme.copyWith(
          inputDecorationTheme: InputDecorationTheme(
              border: InputBorder.none,
              enabledBorder: InputBorder.none,
              focusedBorder: InputBorder.none)),
      child: Scaffold(
        appBar: AppBar(
          iconTheme: IconThemeData(color: R.color.ffffffff),
          title: Text(
            "登录",
            style: TextStyle(color: R.color.ffffffff),
          ),
          elevation: 0,
          backgroundColor: R.color.ff2eab86,
        ),
        body: SingleChildScrollView(
          child: SizedBox(
            height: R.dimen.height - kToolbarHeight,
            child: Stack(
              alignment: AlignmentDirectional.center,
              children: [
                Column(
                  children: [
                    Container(
                      width: R.dimen.width,
                      height: R.dimen.dp214,
                      decoration: BoxDecoration(
                          color: R.color.ff2eab86,
                          borderRadius: BorderRadius.only(
                            bottomLeft: Radius.circular(R.dimen.dp214 / 2),
                            bottomRight: Radius.circular(R.dimen.dp214 / 2),
                          )),
                      child: Column(
                        children: [
                          Container(
                              margin: EdgeInsets.only(
                                  top: R.dimen.dp28, bottom: R.dimen.dp12),
                              child: Image.asset(R.image.loginLogo)),
                          Text(
                            "专注于企业资源合作的商务平台",
                            style: TextStyle(
                                fontSize: R.dimen.sp11,
                                color: R.color.ffffffff),
                          ),
                        ],
                      ),
                    ),
                  ],
                ),
                Positioned(
                    top: R.dimen.dp166 - kToolbarHeight,
                    child: Container(
                      padding: EdgeInsets.only(
                          left: R.dimen.dp20,
                          right: R.dimen.dp20,
                          bottom: R.dimen.dp28),
                      margin: EdgeInsets.symmetric(horizontal: R.dimen.dp20),
                      width: R.dimen.width - R.dimen.dp20 * 2,
                      decoration: BoxDecoration(
                          color: R.color.ffffffff,
                          borderRadius: BorderRadius.circular(R.dimen.sp13)),
                      child: Column(
                        crossAxisAlignment: CrossAxisAlignment.center,
                        children: [
                          Container(
                            padding:
                                EdgeInsets.symmetric(vertical: R.dimen.dp30),
                            child: Text(
                              "开始探索商机",
                              style: TextStyle(
                                  fontWeight: FontWeight.w600,
                                  fontSize: R.dimen.sp16,
                                  color: R.color.ff666666),
                            ),
                          ),
                          Container(
                            decoration: BoxDecoration(
                                color: R.color.fff5f5f5,
                                borderRadius:
                                    BorderRadius.circular(R.dimen.sp5)),
                            child: TextFormField(
                              decoration: InputDecoration(
                                  hintText: "请输入手机号码",
                                  prefixIconConstraints: BoxConstraints(
                                      minHeight:
                                          R.dimen.dp17 + R.dimen.dp13 * 2,
                                      maxHeight:
                                          R.dimen.dp17 + R.dimen.dp13 * 2),
                                  prefixIcon: Padding(
                                    padding: EdgeInsets.symmetric(
                                        vertical: R.dimen.dp13,
                                        horizontal: R.dimen.dp14),
                                    child: Image.asset(R.image.mobile),
                                  )),
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.only(top: R.dimen.dp25),
                            decoration: BoxDecoration(
                                color: R.color.fff5f5f5,
                                borderRadius:
                                    BorderRadius.circular(R.dimen.sp5)),
                            child: TextFormField(
                              decoration: InputDecoration(
                                  hintText: "请输入密码",
                                  prefixIconConstraints: BoxConstraints(
                                      minHeight:
                                          R.dimen.dp17 + R.dimen.dp13 * 2,
                                      maxHeight:
                                          R.dimen.dp17 + R.dimen.dp13 * 2),
                                  prefixIcon: Padding(
                                    padding: EdgeInsets.symmetric(
                                        vertical: R.dimen.dp13,
                                        horizontal: R.dimen.dp14),
                                    child: Image.asset(R.image.lock),
                                  )),
                            ),
                          ),
                          Container(
                            margin: EdgeInsets.only(
                                top: R.dimen.dp16, bottom: R.dimen.dp36),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.spaceBetween,
                              children: [
                                GestureDetector(
                                  onTap: () => Get.toNamed(
                                      Get.currentRoute + AppRoutes.register),
                                  child: Text(
                                    "新用户注册",
                                    style: TextStyle(color: R.color.ff04a3d1),
                                  ),
                                ),
                                Text(
                                  "找回密码",
                                  style: TextStyle(color: R.color.ff04a3d1),
                                )
                              ],
                            ),
                          ),
                          ElevatedButton(
                              onPressed: () {},
                              child: Text(
                                "登录",
                                style: TextStyle(fontSize: R.dimen.sp16),
                              )),
                          Container(
                            margin: EdgeInsets.only(
                                top: R.dimen.dp30, bottom: R.dimen.dp19),
                            child: Row(
                              mainAxisAlignment: MainAxisAlignment.center,
                              children: [
                                Expanded(
                                  child: Container(
                                    height: 1 / 2,
                                    color: R.color.ffdddddd,
                                  ),
                                ),
                                Container(
                                  margin: EdgeInsets.symmetric(
                                      horizontal: R.dimen.dp18),
                                  child: Text(
                                    "第三方登录",
                                    style: TextStyle(
                                        color: R.color.ff979797,
                                        fontSize: R.dimen.sp11),
                                  ),
                                ),
                                Expanded(
                                  child: Container(
                                    height: 1 / 2,
                                    color: R.color.ffdddddd,
                                  ),
                                ),
                              ],
                            ),
                          ),
                          Image.asset(R.image.wechat),
                          Container(
                              margin: EdgeInsets.only(top: R.dimen.dp10),
                              child: Text(
                                "微信登录",
                                style: TextStyle(
                                    color: R.color.ff555555,
                                    fontSize: R.dimen.sp11),
                              ))
                        ],
                      ),
                    )),
                Positioned(
                    top: R.dimen.height - kToolbarHeight - R.dimen.dp108,
                    child: Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        Text(
                          "登录表示您已阅读同意",
                          style: TextStyle(
                              color: R.color.ff979797, fontSize: R.dimen.sp12),
                        ),
                        Text(
                          "《服务协议》",
                          style: TextStyle(
                              color: R.color.ff04a3d1, fontSize: R.dimen.sp12),
                        ),
                        Text(
                          "和",
                          style: TextStyle(
                              color: R.color.ff979797, fontSize: R.dimen.sp12),
                        ),
                        Text("《隐私政策》",
                            style: TextStyle(
                                color: R.color.ff04a3d1,
                                fontSize: R.dimen.sp12))
                      ],
                    ))
              ],
            ),
          ),
        ),
      ),
    );
  }
}

class LoginBackgroundClipper extends CustomClipper<Path> {
  @override
  Path getClip(Size size) {
    final Path path = Path();
    double height = R.dimen.dp97;
    path.moveTo(0, 0);
    path.lineTo(0, size.height - height);
    Offset p1 = Offset(size.width / 2, size.height);
    Offset p2 = Offset(size.width, size.height - height);
    path.quadraticBezierTo(p1.dx, p1.dy, p2.dx, p2.dy);
    path.lineTo(size.width, size.height - height);
    path.lineTo(size.width, 0);

    return path;
  }

  @override
  bool shouldReclip(covariant CustomClipper<Path> oldClipper) => true;
}
